<?php

namespace app\queue\stomp;

use app\queue\BaseConsumer;
use common\service\MessageService;

class SendNotifyMessageConsumerV2 extends BaseConsumer
{

    // 要消费的队列名
    public $queue = 'send_notify_message_v2';

    // 连接名，对应 config/redis_queue.php 里的连接`
    public $connection = 'default';

    /**
     * 消费
     * @param $data
     */
    public function doConsume($data)
    {
        try {
            APP_DEBUG && trace(var_export($data, true), 'DEBUG');
            $param = $data["param"];
            $receiver = $data["receiver"];
            $templateId = $data["template_id"];
            $projectId = $data['project_id'] ?? 0;
            $contentType = $data["content_type"];
            $noticeType = $data['notice_type'];
            $isPopup = $data['is_popup'] ?? false;
            $messageKey = $data['message_key'] ?? "";
            $messageDetailData = $data['detail_data'] ?? [];
            $messageService = MessageService::getInstance();
            $messageService->sendSystemNotifyMessageV2($param, $projectId, $receiver, $templateId, $contentType, $noticeType, $isPopup, $messageKey, $messageDetailData);
        } catch (\Throwable $e) {
            trace(format_exception_info($e), "ERR");
        }
    }

}
